<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>显示限定格式的日期</title>
<style>
	.add1, .add2, .ticket_date { border: 1px solid #7F9DB9; height: 14px; line-height: 14px; margin: 0 3px; padding: 1px 1px 1px 3px; width: 71px; }
	span { color: #07519A; margin-right: 4px; }
	body, input, form, div { font-size: 12px; margin: 0; padding: 0; }
	body { background-color: none; }
	.ticket { margin-top: 6px; }
</style>


</head>

<body>
<form id="tab_1" name="tab_1" action="" target="_blank" method="get">
  <div class="ticket">
      <span>日期</span>
      <input class="ticket_date" id="date" name="date" type="text" value="" />
  </div>
</form>
<script type="text/javascript">
  Date.prototype.format = function (format) {
	  var o = {
		  "M+": this.getMonth() + 1, //month 
		  "d+": this.getDate(),    //day 
		  "h+": this.getHours(),   //hour 
		  "m+": this.getMinutes(), //minute 
		  "s+": this.getSeconds(), //second 
		  "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter 
		  "S": this.getMilliseconds() //millisecond 
	  }
	  if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	  for (var k in o)
		  if (new RegExp("(" + k + ")").test(format))
			  format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
	  return format;
  }
  var nowDate = new Date();
  nowDate.setDate(nowDate.getDate() );
  document.getElementById('date').value = nowDate.format("yyyy-MM-dd");
</script>

</body>
</html>
